package mid;

public class a467_环绕字符串中唯一的子字符串 {
    public int findSubstringInWraproundString(String p) {
        char[] chars = p.toCharArray();
        int length = chars.length;
        int [] res=new int[26];
        res[chars[0]-'a']=1;
        int len=1;
        for (int i = 1; i < length; i++) {
            if ((chars[i]-'a')==(chars[i-1]-'a'+1)%26){
                len++;
            }else {
                len=1;
            }
            res[chars[i]-'a']=Math.max(len,res[chars[i]-'a']);
        }
        int ans=0;
        for (int re : res) {
            ans+=re;
        }
        return ans;
    }
}
